home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: Franz PD
/
Franz PD Disk #015 (19xx)(Amiga User Group Deutschland e.V.).zip
/
Franz PD Disk #015 (19xx)(Amiga User Group Deutschland e.V.).adf
/
ViceTracer
/
Vice-Tracer
< prev
next >
Wrap
Text File
|
1986-10-22
|
8KB
|
291 lines
' V I C E - T R A C E
' geschrieben von
' AMIGA - VICE
'(Roger Hassler/Neustädter Str.14/3252 Bad Mnder 1)
' als Freesoftprogramm
WINDOW CLOSE 1:CLEAR,15000,5000
SCREEN 2,320,256,4,1:WINDOW 2,,,0,2
DEFINT I,j,x,y,f,n:DIM ca(3):DIM grh(81)
GOSUB palettea
PRINT
PRINT
PRINT" A M I G A - V I C E ©"
FOR I=1 TO 10000
NEXT I
CLS
PRINT
PRINT
PRINT" p r e s e n t i e r t
FOR I=1 TO 10000
NEXT I
CLS
PRINT
PRINT" eine ROGER HASSLER Produktion"
FOR I=1 TO 10000
NEXT I
CLS
PRINT
PRINT
PRINT" ***************************** "
PRINT" * V I C E - T R A C E R * "
PRINT" ***************************** "
PRINT
PRINT" Der Spiegel der Wirklichkeit ... "
FOR I=1 TO 17000
NEXT I
CLS
PRINT
PRINT
PRINT" ************************************ "
PRINT" * V I C E - T R A C E R 1.1a * "
PRINT" ************************************ "
PRINT
PRINT" geschrieben von "
PRINT
PRINT" A M I G A - V I C E"
PRINT" als Publick-Domain Programm"
PRINT
PRINT
INPUT"high/low Resolution (1/2) ";nf
IF nf=1 THEN px=632:py=508:ngg=40:nn$="-h" ELSE px=312:py=252:ngg=25:nn$="-l"
DIM g#(ngg)
INPUT"Glas(1)/Diamant(2)/Wasser(3)-Kugel ";GDW$
IF GDW$="1"THEN Kugel%=2.56
IF GDW$="2"THEN Kugel%=5.84
IF GDW$="3"THEN Kugel%=1.78
INPUT"Rechnen/Show (r/s) ";A$
IF A$="s" THEN ON nf GOTO showa,showb
GOSUB aufbau
INPUT"Probelauf (j,n) ";b$
IF b$="n" THEN GOSUB nadenn ELSE GOSUB probe
FOR y=lka TO -bka STEP -1
yh=py*.5-y
IF yh>7 THEN IF MOUSE(0)<0 AND b$="n" THEN GOSUB savebild
IF yh=8 THEN GET(280,0)-(328,7),grh
IF b$="j" OR yh>7 THEN LOCATE 1,36:PRINT y+bka
h1=hsr1+my1*y:h2=hsr2+my2*y:h3=hsr3+my3*y
FOR x=-xm TO xm
farbe=0:ffn=0:faam=0:ns=0
ca1=ca(1):ca2=ca(2):ca3=ca(3)
crr1=llx1*x+h1:crr2=llx2*x+h2:crr3=h3
GOSUB raytracing
PSET(x+xm,bka-y),farbe
NEXT x
NEXT y
BEEP
IF b$="n" THEN GOSUB savebild
SLEEP:SLEEP:SLEEP:RUN
palettea:
WINDOW OUTPUT 2
PALETTE 0,0,0,0:PALETTE 1,0,0,.4:PALETTE 2,0,0,.6:PALETTE 3,0,0,.8
PALETTE 4,0,0,1:PALETTE 5,0,.2,0:PALETTE 6,0,.5,0:PALETTE 7,0,.7,0
PALETTE 8,0,.8,0:PALETTE 9,0,1,0:PALETTE 10,.2,0,0:PALETTE 11,.4,0,0
PALETTE 12,.6,0,0:PALETTE 13,.5,0,0:PALETTE 14,1,0,0:PALETTE 15,1,1,1
COLOR 4,0
RETURN
paletteb:
WINDOW OUTPUT 2
a1=2/15:a2=5/15:a3=7/15:a4=7/15:a5=8/15
PALETTE 16,a1,a1,a1:PALETTE 17,a2,a2,.4:PALETTE 18,a3,a3,.6:PALETTE 19,a4,a4,.8
PALETTE 20,a5,a5,1:PALETTE 21,a1,.2,a1:PALETTE 22,a2,.4,a2:PALETTE 23,a3,.6,a3
PALETTE 24,a4,.8,a4:PALETTE 25,a5,1,a5:PALETTE 26,.2,a1,a1:PALETTE 27,.4,a2,a2
PALETTE 28,.6,a3,a3:PALETTE 29,.8,a4,a4:PALETTE 30,1,a5,a5:PALETTE 31,0,0,0
RETURN
probe:
px=85:py=70
GOSUB init:lka=bka
IF nf=1 THEN RETURN
SCREEN 2,320,256,5,1:WINDOW 2,,(0,0)-(311,242),0,2
GOSUB palettea:GOSUB paletteb
RETURN
nadenn:
IF nf=1 THEN
SCREEN 2,640,525,4,4:WINDOW 2,,(0,9)-(631,508),0,2
GOSUB palettea
ELSE
SCREEN 2,321,280,5,1:WINDOW 2,,(0,9)-(312,262),0,2
GOSUB palettea:GOSUB paletteb
END IF
GOSUB init
INPUT"Neues Bild/Fortsetzung (1/2) ";A$
INPUT"Name des Bildes ? ",na$:CLS
IF A$="1" THEN lka=bka ELSE GOSUB loadbild:lka=bka-I+1:GET(280,0)-(328,7),grh
RETURN
aufbau:
RESTORE
nk=3:DIM ku(nk,4)
FOR I=0 TO nk
FOR j=0 TO 4
READ ku(I,j)
NEXT j
NEXT I
DATA 50,-50,200,200,3
DATA 8,11,48,7,1
DATA 9,42,46,13,1
DATA 6,16,27,5,2
REM ARTEN=Spiegelkugel:1,Glas:2,Lichtquelle:3 !
lqq1=ku(0,1):lqq2=ku(0,2):lqq3=ku(0,3)
RETURN
init:
CLS:farbe=0
xm=px*.5:bka=py*.5
bb=.265:bh=.19:brz1=Kugel%:brz2=1/brz1
PRINT"Ideale Werte währen :"
PRINT"0,0,18"
PRINT"5,10,-2.6"
PRINT"0.28"
PRINT
INPUT "Bildschirmmittelpunkt: ";bm1,bm2,bm3
INPUT "Blickrichtung: ";hsr1,hsr2,hsr3
INPUT "Abstand vom Bildschirm:";ba
IF (hsr1=0 AND hsr2=0) OR ba=0 THEN GOTO init
llx1=hsr2:llx2=-hsr1:llx3=0
bx=SQR(llx1*llx1+llx2+llx3*llx3)
llx1=(llx1*bb)/(bx*px):llx2=(llx2*bb)/(bx*px):llx3=(llx3*bb)/(bx*px)
my1=-hsr1*hsr3:my2=-hsr2*hsr3:my3=hsr2*hsr2+hsr1*hsr1
by=SQR(my1*my1+my2*my2+my3*my3)
my1=(my1*bh)/(by*py):my2=(my2*bh)/(by*by):my3=(my3*bh)/(by*py)
br=SQR(hsr1*hsr1+hsr2*hsr2+hsr3*hsr3)
hsr1=hsr1*ba/br:hsr2=hsr2*ba/br:hsr3=hsr3*ba/br
ca(1)=bm1-hsr1:ca(2)=bm2-hsr2:ca(3)=bm3-hsr3
CLS
RETURN
raytracing:
nsh=-1:kh=0
FOR I=0 TO nk
IF I<>ns THEN
nr=I:GOSUB Kugelschnipp
IF k THEN IF kh=0 OR k<kh THEN nsh=I:kh=k
END IF
NEXT I
IF kh<=0 THEN GOSUB schnittich:RETURN
IF nsh=0 THEN farbe=15:RETURN
ns=nsh:k=kh:nr=ns
ON ku(ns,4) GOSUB kugspiegel,Kugelglas
IF farbe=15 THEN RETURN
GOTO raytracing
Kugelschnipp:
ras1=ca1-ku(nr,1):ras2=ca2-ku(nr,2):ras3=ca3-ku(nr,3)
kffn1=2*(crr1*crr1+crr2*crr2+crr3*crr3)
kffn2=2*(crr1*ras1+crr2*ras2+crr3*ras3)
kffn3=ras1*ras1+ras2*ras2+ras3*ras3-ku(nr,0)*ku(nr,0)
kffn4=kffn2*kffn2-2*kffn1*kffn3:IF kffn4<0 THEN k=0:RETURN
k1=(-kffn2+SQR(kffn4))/kffn1:k2=(-kffn2-SQR(kffn4))/kffn1
k=k1:IF k1>k2 THEN k=k2
RETURN
kugspiegel:
r1=ca1+k*crr1-ku(nr,1):r2=ca2+k*crr2-ku(nr,2):r3=ca3+k*crr3-ku(nr,3)
h=(crr1*r1+crr2*r2+crr3*r3)/(r1*r1+r2*r2+r3*r3)
crr1=crr1-2*h*r1:crr2=crr2-2*h*r2:crr3=crr3-2*h*r3
ca1=r1+ku(nr,1):ca2=r2+ku(nr,2):ca3=r3+ku(nr,3)
ffn=ffn+1
RETURN
Kugelglas:
GOSUB kugelglasreflex:IF kkb=1 THEN farbe=15:RETURN
brz=brz1:GOSUB knackpunkt:GOSUB schnitt2
brz=brz2:GOSUB knackpunkt
ca1=ku(nr,1)-r1:ca2=ku(nr,2)-r2:ca3=ku(nr,3)-r3
IF nf=2 THEN faam=16 ELSE ffn=ffn+2
RETURN
kugelglasreflex:
kkb=1
r1=ca1+k*crr1-ku(nr,1):r2=ca2+k*crr2-ku(nr,2):r3=ca3+k*crr3-ku(nr,3)
h=(crr1*r1+crr2*r2+crr3*r3)/(r1*r1+r2*r2+r3*r3)
puma1=crr1-2*h*r1:puma2=crr2-2*h*r2:puma3=crr3-2*h*r3
cah1=r1+ku(nr,1):cah2=r2+ku(nr,2):cah3=r3+ku(nr,3)
ras1=cah1-ku(0,1):ras2=cah2-ku(0,2):ras3=cah3-ku(0,3)
kffn1=2*(puma1*puma1+puma2*puma2+puma3*puma3)
kffn2=2*(puma1*ras1+puma2*ras2+puma3*ras3)
kffn3=ras1*ras1+ras2*ras2+ras3*ras3-ku(0,0)*ku(0,0)
kffn4=kffn2*kffn2-2*kffn1*kffn3:IF kffn4<0 THEN kkb=0
RETURN
knackpunkt:
r1=ku(nr,1)-ca1-k*crr1:r2=ku(nr,2)-ca2-k*crr2:r3=ku(nr,3)-ca3-k*crr3
gf1=crr1*r1+crr2*r2+crr3*r3:gf2=crr1*crr1+crr2*crr2+crr3*crr3:gf3=r1*r1+r2*r2+r3*r3
gf4=(gf1*gf1)/(gf2*gf3):gf5=(1-gf4)/brz
si=SQR(ABS(gf5)):co=SQR(ABS(1-gf5))
gh1=r2*crr3-r3*crr2=r3*crr1-r1*crr3:gh3=r1*crr2-r2*crr1
g1=gh2*r3-gh3*r2:g2=gh3*r1-gh1*r3:g3=gh1*r2-gh2*r1
gr=co/SQR(ABS(gf3)):gg=si/SQR(ABS(g1*g1+g2*g2+g3*g3))
crr1=r1*gr+g1*gg:crr2=r2*gr+g2*gg:crr3=r3*gr+g3*gg
RETURN
schnitt2:
kffn1=2*(crr1*crr1+crr2*crr2+crr3*crr3)
kffn2=2*(crr1*r1+crr2*r2+crr3*r3)
kffn3=gf3-ku(nr,0)*ku(nr,0)
kffn4=kffn2*kffn2-2*kffn1*kffn3:IF kffn4<0 THEN k=0:RETURN
k1=(-kffn2+SQR(kffn4))/kffn1:k2=(-kffn2-SQR(kffn4))/kffn1
k=k1:IF k1<k2 THEN k=k2
RETURN
schnittich:
IF crr3>=0 THEN IF ffn>3 THEN farbe=0+faam ELSE farbe=4-ffn+faam:RETURN
bodk=ca3/crr3
s1=ca1-bodk*crr1:s2=ca2-bodk*crr2
GOSUB schatten
IF ffn>4 THEN farbe=0+faam:RETURN
IF INT(s1*.05)*2-INT(si*.1)=INT(s2*.05)*2-INT(s2*.1) THEN
farbe=9-ffn+faam
ELSE
farbe=14-ffn+faam
END IF
RETURN
schatten:
fh=0
ca1=s1:ca2=s2:ca3=0
crr1=lqq1-s1:crr2=lqq2-s2:crr3=lqq3
FOR j=1 TO nk
nr=j:GOSUB Kugelschnipp
IF k>0 THEN
IF ku(nr,4)=1 THEN ffn=ffn+2:RETURN
fh=fh+1
END IF
NEXT j
IF fh>2 THEN fh=2
ffn=ffn+fh
RETURN
savebild:
PUT(280,0),grh,PSET:BEEP
OPEN"O",#1,"Picture/"+na$+nn$,5000
FOR I=0 TO yh
GET(0,I)-(px,I),g#
FOR j=0 TO ngg
PRINT#1,MKD$(g#(j));
NEXT j
NEXT I
CLOSE #1:BEEP
RETURN
loadbild:
BEEP
yh=bka-lka:IF yh=0 THEN yh=py
OPEN"I",#1,"Picture/"+na$+nn$,5000
I=0
WHILE NOT EOF(1)
FOR j=0 TO ngg
g#(j)=CVD(INPUT$(8,#1))
NEXT j
PUT(0,I),g#
I=I+1
WEND
CLOSE#1:BEEP
RETURN
showa:
CLS:INPUT"Name (e=ende) ";na$:IF na$="e" THEN RUN
SCREEN 2,640,512,4,4:WINDOW 2,,(0,0)-(631,498),0,2
GOSUB palettea:GOSUB loadbild
SLEEP:SLEEP:SLEEP
GOTO showa
showb:
CLS:INPUT"Name (e=ende) ";na$:IF na$="e" THEN RUN
SCREEN 2,321,257,5,1:WINDOW 2,,(0,0)-(312,243),0,2
GOSUB palettea:GOSUB paletteb:GOSUB loadbild
SLEEP:SLEEP:SLEEP
GOTO showb